package com.hunan.api.catv.utils.captcha.generator;

import cn.hutool.captcha.generator.AbstractGenerator;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;

/**
 * @author jiang zhuan
 * @version 1.0
 * @description 描述
 * @date 2021/1/6 0006
 * @package com.hunan.api.catv.utils.captcha.generator
 * @company 湖南有线
 */
public class NumberGenerator extends AbstractGenerator {


    public NumberGenerator(int count) {
        super(RandomUtil.BASE_NUMBER, count);
    }

    @Override
    public String generate() {
        return RandomUtil.randomString(RandomUtil.BASE_NUMBER, this.length);
    }

    @Override
    public boolean verify(String code, String userInputCode) {
        if (StrUtil.isNotBlank(userInputCode)) {
            return StrUtil.equalsIgnoreCase(code, userInputCode);
        }
        return false;
    }

}
